home *** CD-ROM | disk | FTP | other *** search
- #
- # Demos for 2D Transformations.
- #
- # (c) Gershon Elber, July 1995
- #
-
- comment $
- pause = procedure():
- printf("Press return to continue:", nil());
- $
-
- # include("house");
- House = load("house");
- House1 = House * tx( 0.225 ) * ty( 0.65 ) * sc( 2.0 );
-
- Axes = list( ctlpt( E2, -2, 0 ) + ctlpt( E2, 2, 0 ),
- ctlpt( E2, 0, -2 ) + ctlpt( E2, 0, 2 ) );
- color( Axes, yellow );
- attrib( Axes, "dwidth", 2 );
-
- #
- # 2D transformation's demo.
- #
- view_mat = tz( 0.1 );
- interact( list( view_mat, axes, House1 ) );
-
- #
- # SCALING uniformly.
- #
- scl = cbspline( 3,
- list( ctlpt( E1, 1 ),
- ctlpt( E1, 3 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 1 ) ),
- list( KV_OPEN ) );
- scl = creparam( scl, 0, 1 );
- attrib( House1, "animation", list( scl ) );
- interact( list( Axes, House1 ) );
-
- #
- # SCALING in X and Y operations.
- #
- scl = cbspline( 3,
- list( ctlpt( E1, 1 ),
- ctlpt( E1, 3 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 0 ),
- ctlpt( E1, 1 ) ),
- list( KV_OPEN ) );
- scl_x = creparam( scl, 0, 0.5 );
- scl_y = creparam( scl, 0.5, 1 );
- attrib( House1, "animation", list( scl_x, scl_y ) );
- interact( list( Axes, House1 ) );
-
- #
- # SCALING with NEGATIVE values.
- #
- scl = cbspline( 2,
- list( ctlpt( E1, 1 ),
- ctlpt( E1, -1 ) ),
- list( KV_OPEN ) );
- scl_x = creparam( scl, 0, 0.5 );
- scl_y = creparam( scl, 0.5, 1 );
- attrib( House1, "animation", list( scl_x, scl_y ) );
- interact( list( Axes, House1 ) );
-
- #
- # ROTATION in the plane.
- #
- rot_z = cbspline( 2,
- list( ctlpt( E1, 0 ),
- ctlpt( E1, 360 ),
- ctlpt( E1, 0 ) ),
- list( KV_OPEN ) );
- rot_z = creparam( rot_z, 0, 1 );
- attrib( House1, "animation", list( rot_z ) );
- interact( list( Axes, House1 ) );
-
- #
- # TRANSLATION in the plane.
- #
- mov_xyz = cbspline( 3,
- list( ctlpt( E3, 0.0, 0.0, 0 ),
- ctlpt( E3, 0.7, -0.7, 0 ),
- ctlpt( E3, 0.7, 0.7, 0 ),
- ctlpt( E3, -0.7, -0.7, 0 ),
- ctlpt( E3, 0.0, 0.7, 0 ),
- ctlpt( E3, -0.7, 0.7, 0 ),
- ctlpt( E3, 0.0, 0.0, 0 ) ),
- list( KV_OPEN ) );
- mov_xyz = creparam( mov_xyz, 0, 1 );
- attrib( House1, "animation", list( mov_xyz ) );
- interact( list( Axes, House1 ) );
-
- #
- # COMPOSITION of transformtions.
- #
- House2 = House1 * trans( vector( 0.25, 0.25, 0.0 ) );
-
- Trans1 = trans( vector( -0.1, -0.15, 0.0 ) );
- Rot1 = rotz( 30 );
- Trans2 = trans( vector( 0.1, 0.15, 0.0 ) );
-
- interact( list( Axes, House2 ) );
-
- interact( list( Axes, House2 * Trans1 ) );
-
- interact( list( Axes, House2 * Trans1 * Rot1 ) );
-
- interact( list( Axes, House2 * Trans1 * Rot1 * Trans2 ) );
-
- #
- # Rotate by SHEAR
- #
- HouseFrame = poly( list( point( 0.0, 0.0, 0 ),
- point( 0.5, 0.0, 0 ),
- point( 0.5, 0.8, 0 ),
- point( 0.0, 0.8, 0 ),
- point( 0.0, 0.0, 0 ) ),
- true );
- color( HouseFrame, cyan );
- attrib( HouseFrame, "dwidth", 3 );
-
- House3 = list( House2, HouseFrame ) * tx( -0.25 ) * ty( -0.35 );
- interact( list( House3, Axes ) );
-
- Theta = 65 * Pi / 180;
- XVal = -tan( Theta / 2 );
- YVal = sin( Theta );
- Shear1 = homomat( list( list( 1, XVal, 0, 0 ),
- list( 0, 1, 0, 0 ),
- list( 0, 0, 1, 0 ),
- list( 0, 0, 0, 1 ) ) );
- Shear2 = homomat( list( list( 1, 0, 0, 0 ),
- list( sin( Theta ), 1, 0, 0 ),
- list( 0, 0, 1, 0 ),
- list( 0, 0, 0, 1 ) ) );
- Shear3 = Shear1;
-
- interact( list( House3 * Shear1, Axes ) );
-
- interact( list( House3 * Shear1 * Shear2, Axes ) );
-
- interact( list( House3 * Shear1 * Shear2 * Shear3, Axes ) );
-
- for ( i = 0, 1, 100,
- XVal = -tan( Theta * i / 200 ):
- view( list( House3 *
- homomat( list( list( 1, XVal, 0, 0 ),
- list( 0, 1, 0, 0 ),
- list( 0, 0, 1, 0 ),
- list( 0, 0, 0, 1 ) ) ),
- Axes ), on ) );
- for ( i = 0, 1, 100,
- YVal = sin( Theta * i / 100 ):
- view( list( House3 * Shear1 *
- homomat( list( list( 1, 0, 0, 0 ),
- list( YVal, 1, 0, 0 ),
- list( 0, 0, 1, 0 ),
- list( 0, 0, 0, 1 ) ) ),
- Axes ), on ) );
- for ( i = 0, 1, 100,
- ZVal = -tan( Theta * i / 200 ):
- view( list( House3 * Shear1 * Shear2 *
- homomat( list( list( 1, ZVal, 0, 0 ),
- list( 0, 1, 0, 0 ),
- list( 0, 0, 1, 0 ),
- list( 0, 0, 0, 1 ) ) ),
- Axes ), on ) );
-